home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / DOTPLOT.LI3 < prev    next >
Text File  |  1993-12-23  |  851b  |  32 lines

  1. #    dotplot() plots dot curve of y=f(x) on xy-plane
  2. #    by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  3. #    e.g.    dotplot(x^3,x)
  4.  
  5. dotplot(y_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
  6.     graph,
  7.     getmaxy3:=getmaxy-30,
  8.     getmaxy1:=getmaxy3+1,
  9.     dx:=(xmax-xmin)/(getmaxx-40),
  10.     dy:=(ymax-ymin)/getmaxy3,
  11.     xstep:=dx*10,
  12.     line(40,getmaxy3,getmaxx,getmaxy3),
  13.     line(40,0,40,getmaxy3),
  14.     moveto(0,0),
  15.     writes(ymax),
  16.     moveto(0,getmaxy3),
  17.     writes(ymin),
  18.     moveto(40,getmaxy-20),
  19.     writes(xmin),
  20.     moveto(getmaxx-30,getmaxy-20),
  21.     writes(xmax),
  22.     setviewport(40,0,getmaxx,getmaxy3,1),
  23.     moveto(0,getmaxy3),
  24.     do( putpixel((x-xmin)/dx,getmaxy1-(y-ymin)/dy,15),
  25.     x,xmin,xmax,xstep),
  26.     numeric:=off,
  27.     readchar,
  28.     text,
  29.     local(dx,dy,xstep))
  30. dotplot(y_, x_, xmin_, xmax_) := dotplot(y,x,xmin,xmax,-5,5)
  31. dotplot(y_, x_) := dotplot(y,x,-5,5,-5,5)
  32.